package com.rock.code.bigdata.kbp.controller;


import com.rock.code.base.controller.BaseController;
import com.rock.code.base.domain.AjaxJson;
import com.rock.code.base.domain.Constants;
import com.rock.code.bigdata.kbp.service.TbSysKbpService;
import com.rock.code.common.exceptions.SystemException;
import com.rock.code.common.handover.DataSource;
import com.rock.code.common.tree.ItemNode;
import com.rock.code.system.module.service.TbSysModuleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author piandu
 * @description 综合查询（树）
 * @date 2018/9/14 16/34
 */
@Controller
@RequestMapping("/kbpView")
public class KbpController extends BaseController {

    @Resource
    private TbSysKbpService tbSysKbpServiceImpl;

    @RequestMapping("")
    public String queryKbpView() {
        return "bigdata/kbp/kbpView";
    }

    /*点击触发树*/
    @ResponseBody
    @RequestMapping(value = "/queryTreeData", method = RequestMethod.POST)
    public AjaxJson queryTreeData(String parentCode) throws Exception {
        try {
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("parentCode", parentCode);
            param.put("isDelete", Constants.DELETE_N);
            param.put("orderBy", "VIEW_ORDER asc");
            List<ItemNode> rows = tbSysKbpServiceImpl.queryTreeData(param);
            ajaxJson.setResult(rows);
        } catch (Exception e) {
            e.printStackTrace();
            throw new SystemException(e);
        }
        return ajaxJson;
    }
}

